using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace zeroflag.Parserz.IDE
{
	public partial class MainForm : Form, ISelectedItems<TokenNode>
	{
		public MainForm()
		{
			InitializeComponent();
		}

		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);

			String root = new String();

			root.Value = System.IO.File.ReadAllText("test.cpp");

			root.Value += root.Value;

			this.tokenView.Root = root;
		}

		#region ISelectedItems<object> Members

		List<TokenNode> m_SelectedItems = new List<TokenNode>();

		public List<TokenNode> SelectedItems
		{
			get { return m_SelectedItems; }
			set { this.propertyGrid.SelectedObjects = (m_SelectedItems = value).ToArray(); }
		}

		#endregion


		public static T FindParent<T>(Control ctrl)
			where T : class
		{
			if (ctrl == null)
				return null;
			else if (ctrl is T)
				return ctrl as T;
			else
				return FindParent<T>(ctrl.Parent);
		}
	}
}